package edu.czjtu.geesonke.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import edu.czjtu.geesonke.dto.EmployeeDto;
import edu.czjtu.geesonke.entity.Employee;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface EmployeeMapper extends BaseMapper<Employee> {
    @Select("<script>" +
            "SELECT ep.*, sp.name as shop_name from employee ep left join shop sp on ep.shop_id=sp.id " +
            "where 1=1 " +
            "<if test='employee_name!=null'>" +
            " and ep.`name` LIKE concat('%',#{employee_name},'%') " +
            "</if>" +
            "<if test='shop_name!=null'>" +
            " and sp.`name` LIKE concat('%',#{shop_name},'%')" +
            "</if> order by ep.update_time desc" +
            "</script>")
    IPage<EmployeeDto> selectJoin(IPage<EmployeeDto> page, @Param("employee_name") String employee_name, @Param("shop_name") String shop_name);
}
